<?php

namespace App\Models;


use App\Service\Base\Model;

class Event extends Model
{

    // 活动
    protected $table = 'event';

    // 缓存字段，用于搜索绑定的字段
    protected $cacheFields = ['id', 'uid', 'auth_id', 'event_type'];

    // {"id":"自编号","uid":"用户ID","auth_id":"认证ID（机构学校的ID）","event_type":"认证类型（赛事，研学，沙龙）","event_name":"认证名称","cost":"费用","is_refund":"是否支持退款：1-是","dead_time":"报名截止时间","start_time":"开始时间","end_time":"结束时间","city":"城市","address":"所在地","description":"认证描述","cover":"封面图片","images":"办学许可","is_propose":"是否推荐（1-是）","verify":"是否审核（1-是）","ctime":"注册时间","mtime":"更新时间"}


    // array ( 'id' => '$this->getData("id", null, "trim")', 'uid' => '$this->getData("uid", null, "trim")', 'auth_id' => '$this->getData("auth_id", null, "trim")', 'event_type' => '$this->getData("event_type", null, "trim")', 'event_name' => '$this->getData("event_name", null, "trim")', 'cost' => '$this->getData("cost", null, "trim")', 'is_refund' => '$this->getData("is_refund", null, "trim")', 'dead_time' => '$this->getData("dead_time", null, "trim")', 'start_time' => '$this->getData("start_time", null, "trim")', 'end_time' => '$this->getData("end_time", null, "trim")', 'city' => '$this->getData("city", null, "trim")', 'address' => '$this->getData("address", null, "trim")', 'description' => '$this->getData("description", null, "trim")', 'cover' => '$this->getData("cover", null, "trim")', 'images' => '$this->getData("images", null, "trim")', 'is_propose' => '$this->getData("is_propose", null, "trim")', 'verify' => '$this->getData("verify", null, "trim")', 'ctime' => '$this->getData("ctime", null, "trim")', 'mtime' => '$this->getData("mtime", null, "trim")', )


    // $id = $this->getData("id", null, 'trim'); $uid = $this->getData("uid", null, 'trim'); $auth_id = $this->getData("auth_id", null, 'trim'); $event_type = $this->getData("event_type", null, 'trim'); $event_name = $this->getData("event_name", null, 'trim'); $cost = $this->getData("cost", null, 'trim'); $is_refund = $this->getData("is_refund", null, 'trim'); $dead_time = $this->getData("dead_time", null, 'trim'); $start_time = $this->getData("start_time", null, 'trim'); $end_time = $this->getData("end_time", null, 'trim'); $city = $this->getData("city", null, 'trim'); $address = $this->getData("address", null, 'trim'); $description = $this->getData("description", null, 'trim'); $cover = $this->getData("cover", null, 'trim'); $images = $this->getData("images", null, 'trim'); $is_propose = $this->getData("is_propose", null, 'trim'); $verify = $this->getData("verify", null, 'trim'); $ctime = $this->getData("ctime", null, 'trim'); $mtime = $this->getData("mtime", null, 'trim');

    // 认证类型
    public function getType($getKey = true)
    {
        //活动类型（赛事game,  研学study，沙龙salon）
        $channels = [
            'game'  => '赛事',
            'salon' => '沙龙',
            'study' => '研学',
        ];

        if(empty($getKey)){
            return $channels;
        }

        return array_keys($channels);
    }

    // 定义验证操作
    public function rules()
    {

        $add = [
            'uid'     => 'required',
            'auth_id' => 'required',
        ];

        $edit = [
        ];

        $info = [
        ];


        $rule = [
            'event_type'   => 'required',
            'event_name'   => 'required',
            'organ_price'  => 'required',
            'person_price' => 'required',
            'is_refund'    => 'required',
            'dead_time'    => 'required',
            //'start_time'  => 'required',
            //'end_time'    => 'required',
            'city'         => 'required',
            'address'      => 'required',
            //'description' => 'required',
            //'cover'       => 'required',
            //'images'      => 'required',
            //'is_propose'  => 'required',
            'verify'       => ['in:-1,0,1,2'],
            //'status' => ['in:-1,0,1,2'],
        ];


        $msg = [
            'id'           => '自编号',
            'uid'          => '用户ID',
            'auth_id'      => '认证ID（机构学校的ID）',
            'event_type'   => '认证类型（赛事，研学，沙龙）',
            'event_name'   => '认证名称',
            'organ_price'  => '机构价格',
            'person_price' => '个人价',
            'is_refund'    => '是否支持退款：1-是',
            'dead_time'    => '报名截止时间',
            'start_time'   => '开始时间',
            'end_time'     => '结束时间',
            'city'         => '城市',
            'address'      => '所在地',
            'description'  => '认证描述',
            'cover'        => '封面图片',
            'images'       => '办学许可',
            'is_propose'   => '是否推荐（1-是）',
            'verify'       => '是否审核（1-是）',
            'ctime'        => '注册时间',
            'mtime'        => '更新时间',
        ];

        return ['rule' => $rule, 'msg' => $msg, 'add' => $add];
    }
}
